//
//  RegisterViewController.m
//  TaurusXi
//
//  Created by xicheng on 15/12/7.
//  Copyright © 2015年 xicheng. All rights reserved.
//

#import "RegisterViewController.h"
#import "PhoneCodeViewController.h"
#import "Api.h"

@interface RegisterViewController ()
@property (weak, nonatomic) IBOutlet UIButton *verifyPhoneBt;
@property (weak, nonatomic) IBOutlet UITextField *phoneField;
@property (weak, nonatomic) IBOutlet UITextField *codeField;
@property (weak, nonatomic) IBOutlet UIImageView *codeImageView;

@end

@implementation RegisterViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
  [self setTitleText:@"注册"];
  [self.verifyPhoneBt addTarget:self action:@selector(verifyPhoneBt:) forControlEvents:UIControlEventTouchUpInside];
  [self.codeImageView sd_setImageWithURL:[NSURL URLWithString:[[Api shareApiInstance] getCodeStatusPath]]];
  
}

-(void)verifyPhoneBt:(UIButton *)sender{
  
  [self showSimplePro];
  @weakify(self);
  [[Api shareApiInstance] registerFirstWithPhoneNumb:self.phoneField.text AndCode:self.codeField.text AndCodeUUID:[Api shareApiInstance].codeUUID AndResponce:^(id object) {
    @strongify(self);
    [self hideSimpleProWithDelay:0];
    if([[object objectForKey:@"code"] isEqualToString:@"10000"]){
      PhoneCodeViewController *phoneVC = [[PhoneCodeViewController alloc]initWithNibName:@"PhoneCodeViewController" bundle:nil];
      
      phoneVC.smsId = [object objectForKey:@"smsId"];
      phoneVC.phoneNumbStr = self.phoneField.text;
      [self.navigationController pushViewController:phoneVC animated:YES];
    }
    
    
  } AndError:^(id object, NSError *error) {
    @strongify(self);
    [self hideSimpleProWithDelay:0];
  }];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}




@end
